package com.assist.utils
{
	public class IntUtil
	{
		public static function format(i:*, width:uint, blankfilled:String='0') : String
		{
			if (!(i is int || i is uint)) {
				throw new Error("i not int or uint, invalid type");				
			}
			
			var iAbs:uint;
			var negtive:Boolean = i < 0;
			if (negtive) {
				iAbs = -i;
			}
			else {
				iAbs = i;
			}

			var s:String = iAbs.toString();
			var needWidth:int = width - s.length;
			var array:Array = [];

			if (negtive) {
				array.push('-');
				--needWidth;
			}
			
			while (needWidth > 0) { 
				array.push(blankfilled);
				--needWidth;
			}

			return array.join("") + s;
		}
	}
}